<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CommonPageMenuInput.ascx.cs" Inherits="admin_webparts_Plug_ins_CommonPage_CommonPageMenuInput" %>

<%@ Import Namespace="NTTHAO.Common.BL" %>
<%@ Import Namespace="NTTHAO.Web.BL.ImageAlbum" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>

<script type="text/javascript">
NTTHAO.namespace('page');

NTTHAO.page.langText = [];
NTTHAO.page.langText['BLANK_MENU_NAME'] = '<%=LanguageUtility.GetLanguageText("BLANK_MENU_NAME", Session)%>';
NTTHAO.page.langText['BLANK_URL'] = '<%=LanguageUtility.GetLanguageText("BLANK_URL", Session)%>';
NTTHAO.page.langText['INVALID_NUMBER'] = '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER", Session)%>';

function doSubmit() {
    var txtMenuText = document.getElementById("<%=this.txtMenuText.ClientID %>");
    var chkUseURL = document.getElementById("<%=this.chkUseURL.ClientID %>");
    var txtURL = document.getElementById("<%=this.txtURL.ClientID %>");
    //var txtViewType = document.getElementById("=this.txtViewType.ClientID");
    
    var errorMessage = "";

    errorMessage = CheckFieldString("noblank", txtMenuText, NTTHAO.page.langText['BLANK_MENU_NAME']);
    if(errorMessage != "")
    {
        alert(errorMessage);
        txtMenuText.select();
        txtMenuText.focus();
        return false;
    }
    
    if(chkUseURL.checked) {
        errorMessage = CheckFieldString("noblank", txtURL, NTTHAO.page.langText['BLANK_URL']);
        if(errorMessage != "")
        {
            alert(errorMessage);
            txtURL.select();
            txtURL.focus();
            return false;
        }
    }
<%if (isAdmin) { %>
    /*
    errorMessage = CheckFieldString("noblank", txtViewType, NTTHAO.page.langText['INVALID_NUMBER']);
    errorMessage += CheckFieldString("integer", txtViewType, NTTHAO.page.langText['INVALID_NUMBER']);
    if(errorMessage != "")
    {
        alert(errorMessage);
        txtViewType.select();
        txtViewType.focus();
        return false;
    }
    */
<%} %>
    return true;
}
</script>
<style type="text/css">
    #spCancel1, #spSave, #spCancel2, #spSave2 {font-size:1.1em; font-weight: bold; }
    #spCancel1 button, #spSave button, #spCancel2 button, #spSave2 button { font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; }
</style>

<div class="tip">
	<h2 style="padding-top: 2px;"><%=LanguageUtility.GetLanguageText("MENU_INPUT", Session)%></h2>
</div>
<form id="frmInput" runat="server" onsubmit="return doSubmit();">
<p style="text-align: left;">
    <span id="spSave" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" /></span></span>
    <span id="spCancel1" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="<%=_ReturnUrl %>"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
    <script type="text/javascript">
        YAHOO.util.Event.onContentReady("spSave", function () {
            var spSave = new YAHOO.widget.Button("spSave");
        });
        YAHOO.util.Event.onContentReady("spCancel1", function () {
            var spCancel1 = new YAHOO.widget.Button("spCancel1");
        });
    </script>
</p>
<table cellspacing="0" cellpadding="3" border="1" class="grid" style="margin: 10px auto;">
    <tr class="even">
        <td align="right">
            <%=LanguageUtility.GetLanguageText("MENU_TEXT", Session)%><span style="color: #ff0000;">&nbsp;*</span>
        </td>
        <td>
            <asp:TextBox ID="txtMenuText" runat="server" Width="400px"></asp:TextBox>
        </td>
    </tr>
    <tr class="odd">
        <td align="right">
            <%=LanguageUtility.GetLanguageText("DESCRIPTION", Session)%>:</td>
        <td>
            <asp:TextBox ID="txtDescription" runat="server" Width="400px" Height="100px" TextMode="MultiLine"></asp:TextBox>
        </td>
    </tr>
    <tr class="even">
        <td align="right"><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%>:</td>
        <td>
            <asp:CheckBox ID="chkActive" runat="server" Text="Active" Checked="true" /></td>
    </tr>
    <tr class="odd" style="height: 32px; display:<%=isAdmin?"":"none" %>">
        <td colspan="2"><b>For admin</b></td>
    </tr>
    <tr class="even" style="display:<%=isAdmin?"":"none" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("CONTENT_TYPE", Session)%>:</td>
        <td>
            <asp:DropDownList runat="server" ID="cmbContentType" Width="200px">
            </asp:DropDownList>
        </td>
    </tr>
    <tr class="odd" style="display: none;" id="trHyperlink">
        <td align="right">
            <%=LanguageUtility.GetLanguageText("HYPERLINK", Session)%>:</td>
        <td>
            <asp:TextBox ID="txtContentURL" runat="server" Width="400px"></asp:TextBox>
        </td>
    </tr>
    <tr class="even" style="display:<%=isAdmin?"":"none" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("TARGET", Session)%>:</td>
        <td>
            <asp:DropDownList runat="server" ID="cmbContentTarget" Width="200px">
                <asp:ListItem Value="_self">Self</asp:ListItem>
                <asp:ListItem Value="_blank">Blank</asp:ListItem>
                <asp:ListItem Value="_parent">Parent</asp:ListItem>
                <asp:ListItem Value="_top">Top</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr class="odd" style="display:<%=isAdmin?"":"none" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("USE_URL", Session)%>:</td>
        <td><asp:CheckBox ID="chkUseURL" runat="server" Text="Yes" Checked="false" /></td>
    </tr>
    <tr class="even" style="display:<%=isAdmin?"":"none" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("URL", Session)%>:</td>
        <td>
            <asp:TextBox ID="txtURL" runat="server" Width="400px"></asp:TextBox>
        </td>
    </tr>
</table>
<p style="text-align: left;">
    <span id="spSave2" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><asp:Button ID="btnSave2" runat="server" OnClick="btnSave_Click" Text="Save" /></span></span>
    <span id="spCancel2" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="<%=_ReturnUrl %>"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
    <script type="text/javascript">
        YAHOO.util.Event.onContentReady("spSave2", function () {
            var spSave2 = new YAHOO.widget.Button("spSave2");
        });
        YAHOO.util.Event.onContentReady("spCancel2", function () {
            var spCancel2 = new YAHOO.widget.Button("spCancel2");
        });
    </script>
</p>
</form>
<script type="text/javascript">

function viewTypeChange() {
    if (document.getElementById('<%=cmbContentType.ClientID %>').value == '2') {
        document.getElementById('trHyperlink').style.display = '';
    } else {
        document.getElementById('trHyperlink').style.display = 'none';
    }
}

YAHOO.util.Event.onDOMReady(function() {
    //if(document.getElementById("<%=txtMenuText.ClientID %>").value == "") {
        document.getElementById("<%=txtMenuText.ClientID %>").focus();
    //}
    
    YAHOO.util.Event.addListener("<%=cmbContentType.ClientID %>", "change", viewTypeChange);
    viewTypeChange();
});
</script>